package com.qn.validation.helper;

import com.qn.validation.annotation.AssertTrueOn;
import com.qn.validation.annotation.NotNullOn;
import jakarta.validation.ConstraintValidator;
import org.hibernate.validator.internal.constraintvalidators.bv.AssertTrueValidator;
import org.hibernate.validator.internal.constraintvalidators.bv.NotNullValidator;

import java.util.HashMap;
import java.util.Map;

/**
 * 上下文支持类
 *
 * @author QN
 * @date 2024/12/30
 */
public class SupportContext {

    public static final Map<String, ConstraintValidator> MAP = new HashMap<>();

    public static ConstraintValidator getValidator(String className) {
        return MAP.get(className);
    }

    static {
        MAP.put(NotNullOn.class.getName(), new NotNullValidator());
        MAP.put(AssertTrueOn.class.getName(), new AssertTrueValidator());
    }

}